package com.macasa.panel.common.utils;

import java.util.ArrayList;
import java.util.List;

/**
 * Tool Class for safety cast
 * 
 * @author Mickaël Husson
 * @date 01/01/2012
 */
public class CastHelpers {

	public static <T> T cast(final Object toCast, final Class<T> destType) {
		return destType.cast(toCast);
	}

	public static <T> List<T> castList(final Class<? extends T> clazz, final List<?> c) {
		final List<T> r = new ArrayList<T>(c.size());
		for (final Object o : c) {
			r.add(clazz.cast(o));
		}
		return r;
	}

}
